import { useEffect } from 'react';
import { Button } from 'antd';
import { sendMsg, listenMsg } from '@/views/communication/BroadcastChannel/BroadcastChannel';
import { useUrlParams } from '@/utils/openWindowFeature';

const TargetBlank = () => {
	const obj = useUrlParams<{ name: string; age: string }>();

	useEffect(() => {
		const close = listenMsg((data) => {
			console.log('-=====: ', data);
		});
		console.log(window);
		return () => close();
	}, []);

	const sendData = () => {
		sendMsg({ name: 'frank' });
	};

	return <Button onClick={sendData}>发送跨页面数据</Button>;
};

export default TargetBlank;
